Scrubbable numbers
Try clicking and dragging the numbers in the text below:
If Alice has
...then Alice has 17 apples left.
Examples
We define a variable x
as a scrubbable number like so:
1005
Using interpolation (with $
), you can write this definition inside Markdown text:
If Alice has
20
Arguments
Besides an initial value, a scrubbable number also has an array of possible values that can be reached.
When you pass a single number to Scrubbable
, this array is automatically created. Have a look at the minimum and maximum allowed values of the following scrubbables:
(Here we created a Scrubbable
on its own, without binding its value to a variable. Not very useful!)
You can also specify the array manually:
If no default
is specified, the middle value is used.
Formatting
The library d3-format
is used to format floating-point numbers. You can specify a format string like ".2f"
to be used to format the scrubbable value. Have a look at their documentation to see more examples.
I spent € 30M on Pluto.jl stickers
And it was worth it!
Appendix
What is a good default range?
default_range (generic function with 1 method)
0.1
0.125893
0.158489
0.199526
0.251189
0.316228
0.398107
0.501187
0.630957
0.794328
1.0
1.25893
1.58489
1.99526
2.51189
3.16228
3.98107
5.01187
6.30957
7.94328
10.0
default_range (generic function with 2 methods)
Integer inputs become integer ranges with constant step:
0
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
0
200
400
600
800
1000
1200
1400
1600
1800
2000
2200
2400
2600
2800
3000
3200
3400
3600
3800
4000
Floating points get a logarithmic scale across one order of magnitude:
100000.0
1.25893e5
1.58489e5
1.99526e5
2.51189e5
3.16228e5
3.98107e5
5.01187e5
6.30957e5
7.94328e5
1.0e6
1.25893e6
1.58489e6
1.99526e6
2.51189e6
3.16228e6
3.98107e6
5.01187e6
6.30957e6
7.94328e6
1.0e7
-20.0
-15.8866
-12.6191
-10.0237
-7.96214
-6.32456
-5.02377
-3.99052
-3.16979
-2.51785
-2.0
-1.58866
-1.26191
-1.00237
-0.796214
-0.632456
-0.502377
-0.399052
-0.316979
-0.251785
-0.2
Zero becomes a range around zero:
-10:10
-1.0:0.1:1.0
Definition
Scrubbable